package com.softa.web.migration;

import com.alibaba.fastjson.JSON;
import com.softa.common.sysconfig.flyway.AbstractBaseJavaMigration;
import lombok.extern.slf4j.Slf4j;
import org.flywaydb.core.api.migration.Context;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 * description goes here.
 *
 * @author 杨磊
 * @date 2019/5/9 22:30
 * @since 1.0
 **/
@Slf4j
public class V0_0_3__Init_Test extends AbstractBaseJavaMigration {

    @Override
    public void jdbcMigrate(JdbcTemplate jdbc) {

        List<String> loginCodeList = jdbc.query("select username from sys_user", new RowMapper<String>() {
            @Override
            public String mapRow(ResultSet resultSet, int i) throws SQLException {
                return resultSet.getString("username");
            }
        });

        log.debug("flyway username = {}", JSON.toJSONString(loginCodeList));
    }

}
